home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / programming / amos / amoslist-0295.lzh / AMOSLIST / text0073.txt < prev    next >
Encoding:
Text File  |  1995-03-01  |  2.5 KB  |  106 lines

  1. Hi all.
  2.  
  3. Last month i got frpm Aminet Proclib30 for AMOS and AMOS Pro.
  4. I found some very interesting input routines for real and integer
  5. numbers and for strings. So i modified these procedures for
  6. binary an hexadecimal numbers.
  7. These are the modified procedures:
  8.  
  9.  
  10. Procedure B_INPUT[L]
  11.    '
  12.    ' INPUT ROUTINE FOR BINARY NUMBERS 
  13.    '
  14.    ' L   : Length of field (Default character % exclused).  
  15.    '
  16.    '
  17.    ' This routine accepts only the numbers 0 and 1  
  18.    ' (Plus RETURN to end and BACKSPACE to delete the last character.) 
  19.    ' Characters "%"(for binary numbers) is for default. 
  20.    ' It is therefore more fool-proof than the normal INPUT command. 
  21.    '
  22.    '
  23.    '
  24.    ' Basic routine written in 1994 by Christian Mumenthaler 
  25.    ' Revisioned for Binary Numbers by Luca Ferraris - 02/95 
  26.    ' This routine is Public Domain. Use it wherever you want to.  
  27.    '
  28.    '
  29.    NA$="%"
  30.    Z=Len(NA$)
  31.    L1=L-Z
  32.    Print NA$+Space$(L1);
  33.    Cmove -L1,0
  34.    Curs On 
  35.    A1=Asc("0") : A2=Asc("1")
  36.    Repeat 
  37.       A$=Inkey$
  38.       A$=Upper$(A$)
  39.       A=Asc(A$)
  40.       If((A>=A1 and A<=A2)) and Z<=L
  41.          Print A$;
  42.          NA$=NA$+A$
  43.          Inc Z
  44.       End If 
  45.       If A$=Chr$(8) and Z>0
  46.          Z=Z-1
  47.          Cmove -1,0 : Print " "; : Cmove -1,0
  48.          NA$=Left$(NA$,Len(NA$)-1)
  49.       End If 
  50.    Until A$=Chr$(13)
  51.    Curs Off 
  52.    A#=Val(NA$)
  53. End Proc[A#]
  54.  
  55.  
  56. Procedure H_INPUT[L]
  57.    '
  58.    ' INPUT ROUTINE FOR HEXADECIMAL NUMBERS  
  59.    '
  60.    ' L   : Length of field (Default character "$" exclused).  
  61.    '
  62.    '
  63.    ' This routine accepts only the numbers from 0 to 9 and characters 
  64.    ' from A to F.   
  65.    ' (Plus RETURN to end and BACKSPACE to delete the last character.) 
  66.    ' Characters "$"(for binary numbers) is for default. 
  67.    ' It is therefore more fool-proof than the normal INPUT command. 
  68.    '
  69.    '
  70.    '
  71.    ' Basic routine written in 1994 by Christian Mumenthaler 
  72.    ' Revisioned for Hexadecimal Numbers by Luca Ferraris - 02/95  
  73.    ' This routine is Public Domain. Use it wherever you want to.  
  74.    '
  75.    '
  76.    NA$="$"
  77.    Z=Len(NA$)
  78.    L1=L-Z
  79.    Print NA$+Space$(L1);
  80.    Cmove -L1,0
  81.    Curs On 
  82.    A1=Asc("0") : A2=Asc("F")
  83.    Repeat 
  84.       A$=Inkey$
  85.       A$=Upper$(A$)
  86.       A=Asc(A$)
  87.       If((A>=A1 and A<=A2)) and Z<=L
  88.          Print A$;
  89.          NA$=NA$+A$
  90.          Inc Z
  91.       End If 
  92.       If A$=Chr$(8) and Z>0
  93.          Z=Z-1
  94.          Cmove -1,0 : Print " "; : Cmove -1,0
  95.          NA$=Left$(NA$,Len(NA$)-1)
  96.       End If 
  97.    Until A$=Chr$(13)
  98.    Curs Off 
  99.    A#=Val(NA$)
  100. End Proc[A#]
  101.  
  102. Hallo from Luca Ferraris (aldo@di.unito.it)
  103. -------------------------------------------
  104.  
  105.  
  106.